package com.ruicar.afs.cloud.batch.controller;

import com.ruicar.afs.cloud.batch.frame.control.BatchControl;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * The type BatchController
 * <p>Description: </p>
 *
 * @author Fzero
 * @version 1.0
 * @date Created on 2020.08.07 17:37:26
 * @since 1.0
 */
@RestController
@Slf4j
@RequestMapping("/batch")
@AllArgsConstructor
public class BatchController {
    /**
     * Start batch response
     *
     * @param systemName system name
     * @param batchNo    batch no
     * @return the response
     */
    @PostMapping("/startBatch")
    public IResponse<Boolean> startBatch(@RequestParam String systemName,@RequestParam String batchNo){
        BatchControl.startBatch(systemName,batchNo);
        return IResponse.success(Boolean.TRUE);
    }

    /**
     * Start batch response
     *
     * @param systemName system name
     * @return the response
     */
    @PostMapping("/resetError")
    public IResponse<Boolean> resetError(@RequestParam String systemName){
        BatchControl.resetError(systemName);
        return IResponse.success(Boolean.TRUE);
    }
}
